<page-header-wrapper [title]="PageStatus" [logo]="logo">
  <ng-template #logo>
    <button nz-button nz-tooltip nzTooltipTitle="返回上一页" (click)="goBack()">
      <i nz-icon nzType="left" nzTheme="outline"></i>
    </button>
  </ng-template>
</page-header-wrapper>
<div class="custom-style">
  <nz-card>
    <div class="card-title">货源单设置</div>
    <sf #sf1 [schema]="schema1" [formData]="sf1data" [button]="'none'" [ui]="ui1"></sf>
  </nz-card>

  <nz-card>
    <div class="card-title">装卸货信息<span class="tip-font">预计公里数：<em>{{ totalDistance }}km</em>，预计行程耗时：<em>{{ totalTime }}小时</em></span>
    </div>

    <form nz-form [formGroup]="validateForm1" role="form">
      <div nz-row [nzGutter]="24">
        <div nz-col [nzSpan]="10">
          <div *ngFor="let data1 of startInfo; let idx = index">
            <nz-form-item>
              <nz-form-label [nzSpan]="4" nzRequired>装货地</nz-form-label>
              <nz-form-control [nzErrorTip]="'请输入装货地'">
                <div class="align-center">
                  <nz-input-group [nzSuffix]="endInconTemp1">
                    <input nz-input [(ngModel)]="data1.detailedAddress" (click)="openMap('start', idx)"
                      formControlName="loadAddress{{ idx }}" placeholder="请输入装货地" readonly="true" />
                  </nz-input-group>
                </div>
              </nz-form-control>
            </nz-form-item>
            <nz-form-item>
              <nz-form-label [nzSpan]="4" nzRequired>联系人</nz-form-label>
              <div nz-col [nzSpan]="20">
                <div nz-row [nzGutter]="12">
                  <nz-form-control [nzSpan]="12" [nzErrorTip]="'请输入联系人姓名'">
                    <input nz-input [(ngModel)]="data1.appUserName" formControlName="loadName{{ idx }}"
                      name="loadName{{ idx }}" maxlength="30" placeholder="请输入联系人姓名" />
                  </nz-form-control>
                  <nz-form-control [nzSpan]="12" [nzErrorTip]="'请输入联系人电话'">
                    <input nz-input [(ngModel)]="data1.contractTelephone" maxlength="11" (ngModelChange)="onChangePhone(data1.contractTelephone)"
                      formControlName="loadPhone{{ idx }}" name="loadPhone{{ idx }}" placeholder="请输入联系人电话" />
                  </nz-form-control>
                </div>
              </div>
            </nz-form-item>
          </div>
        </div>
        <div nz-col [nzSpan]="4">
          <div class="icon-wrap">
            <span class="swap-icon" (click)="swapAddress()"></span>
          </div>
        </div>
        <div nz-col [nzSpan]="10">
          <div *ngFor="let data2 of endInfo; let idx = index">
            <nz-form-item>
              <nz-form-label [nzSpan]="4" nzRequired>卸货地</nz-form-label>
              <nz-form-control [nzErrorTip]="'请输入卸货地'">
                <div class="align-center">
                  <nz-input-group [nzSuffix]="endInconTemp1">
                    <input nz-input [(ngModel)]="data2.detailedAddress" (click)="openMap('end', idx)"
                      formControlName="unloadAddress{{ idx }}" placeholder="请输入卸货地" readonly="true" />
                  </nz-input-group>
                </div>
              </nz-form-control>
            </nz-form-item>
            <nz-form-item>
              <nz-form-label [nzSpan]="4" nzRequired>联系人</nz-form-label>
              <div nz-col [nzSpan]="20">
                <div nz-row [nzGutter]="12">
                  <nz-form-control [nzSpan]="12" [nzErrorTip]="'请输入联系人姓名'">
                    <input nz-input [(ngModel)]="data2.appUserName" maxlength="30" formControlName="unloadName{{ idx }}"
                      name="unloadAddress{{ idx }}" placeholder="请输入联系人姓名" />
                  </nz-form-control>
                  <nz-form-control [nzSpan]="12" [nzErrorTip]="'请输入联系人电话'">
                    <input nz-input [(ngModel)]="data2.contractTelephone" (ngModelChange)="onChangePhone(data2.contractTelephone)"
                      formControlName="unloadPhone{{ idx }}" name="unloadAddress{{ idx }}" maxlength="11"
                      placeholder="请输入联系人电话" />
                  </nz-form-control>
                </div>
              </div>
            </nz-form-item>
          </div>
        </div>
      </div>
      <ng-template #endInconTemp1><i nz-icon nzType="environment" nzTheme="outline"></i></ng-template>
    </form>
  </nz-card>

  <nz-card>
    <div class="card-title">货物信息</div>
    <div nz-row>
      <div nz-col nzSpan="24">
        <sf #sf3 [schema]="schema3" class="sf3" [formData]="sf3data" [button]="'none'" [ui]="ui3">
          <ng-template class="1" sf-template="goodsTips" let-i let-ui="ui">
            <nz-alert class="goods_tips" nzType="warning" [nzMessage]="tpl" nzShowIcon></nz-alert>
          </ng-template>
          <ng-template #tpl>
            <span style="font-size: 14px;"> 国家法规及行政命令禁限运货物不能托运
              <a target="_blank" [queryParams]="{ type: 15 }" [routerLink]="['/passport/agreement']">《禁运物品说明》</a>
            </span>
          </ng-template>
        </sf>
        <sf #sf4 [schema]="schema4" [formData]="sf4data" [button]="'none'" [ui]="ui4">
          <ng-template sf-template="freightPrice" let-i let-ui="ui">
            <nz-input-group [nzAddOnAfter]="addOnAfterTemplate">
              <nz-input-number [nzMax]="99999" [nzMin]="0" nzPlaceHolder="请输入" type="number" [ngModel]="i.value"
                (ngModelChange)="i.setValue($event)" [nzPrecision]="2" style="width: 100%;border-radius: 4px 0 0 4px;"></nz-input-number>
            </nz-input-group>
            <ng-template #addOnAfterTemplate>
              <nz-select [ngModel]="sf4.value.freightType" (ngModelChange)="sf4.setValue('/freightType', $event)">
                <nz-option [nzValue]="item.value" [nzLabel]="item.label" *ngFor="let item of freightTypeOptions">
                </nz-option>
              </nz-select>
            </ng-template>
          </ng-template>
          <ng-template sf-template="rule" let-i let-ui="ui">
            <div class="align-center">
              <nz-select [ngModel]="i.value" (ngModelChange)="i.setValue($event)" nzPlaceHolder="运费取整规则">
                <nz-option nzLabel="保留小数" nzValue="1"></nz-option>
                <nz-option nzLabel="抹除小数" nzValue="2"></nz-option>
                <nz-option nzLabel="抹除个数" nzValue="3"></nz-option>
              </nz-select>
              <span style="padding: 0 12px" nz-tooltip [nzTooltipTitle]="template2" nzTooltipPlacement="bottom"><i
                  nz-icon nzType="exclamation-circle" nzTheme="outline" style="color: #1890ff"></i></span>
              <ng-template #template2>
                <p>例如 付司机运费 = 重量*单价 = 999.99</p>
                <p>保留小数，即 999.99</p>
                <p>抹除小数，即 999.00</p>
                <p>抹除个位，即 990.00</p>
              </ng-template>
            </div>
          </ng-template>
          <ng-template sf-template="weight" let-i let-ui="ui">
            <nz-input-group [nzAddOnAfter]="'吨'">
              <nz-input-number placeholder="总重量，必填" [ngModel]="i.value" (ngModelChange)="i.setValue($event)" [nzMin]="1"
                style="width: 100%;border-radius: 4px 0 0 4px;"></nz-input-number>
            </nz-input-group>
          </ng-template>
          <ng-template sf-template="volume" let-i let-ui="ui">
            <nz-input-group [nzAddOnAfter]="'方'">
              <nz-input-number placeholder="总体积" [ngModel]="i.value" (ngModelChange)="i.setValue($event)" [nzMin]="1"
                style="width: 100%;border-radius: 4px 0 0 4px;"></nz-input-number>
            </nz-input-group>
          </ng-template>
          <ng-template sf-template="number" let-i let-ui="ui">
            <nz-input-group [nzAddOnAfter]="'车'">
              <nz-input-number placeholder="总车次" [ngModel]="i.value" (ngModelChange)="i.setValue($event)" [nzMin]="1"
                style="width: 100%;border-radius: 4px 0 0 4px;"></nz-input-number>
            </nz-input-group>
          </ng-template>
        </sf>
      </div>
    </div>
  </nz-card>

  <nz-card>
    <div class="card-title">补充信息</div>
    <div nz-row>
      <div nz-col nzSpan="24">
        <sf #sf7 [schema]="schema7" [formData]="sf7data" [button]="'none'" [ui]="ui7">
          <ng-template sf-template="paymentDays" let-i let-ui="ui">
            <div nz-row>
              <div class="align-center">
                <div nz-col nzSpan="14">
                  <nz-input-number [(ngModel)]="i.value" (ngModelChange)="i.setValue($event)" [nzMin]="1" [nzMax]="30"
                    [nzStep]="1"></nz-input-number>
                </div>
                <div nz-col nzSpan="10">
                  <span>&nbsp;天内支付运费</span>
                </div>
              </div>
            </div>
          </ng-template>
        </sf>
      </div>
    </div>
  </nz-card>
  <nz-card class="btn-wrap">
    <div class="align-center">
      <label style="margin-right: 10px;" nz-checkbox [(ngModel)]="agreement"></label> 
      我已阅读并同意 
      <span style="color: blue;" (click)="submitConfirm('agreement')">《运输协议》</span>
    </div>
    <div class="align-center" style="margin-top: 10px;">
      <button nz-button nzType="primary" (click)="submitConfirm('qrcode')" acl
        [acl-ability]="['SUPPLY-VEHICLE-PLACEORDER- QRCode']">生成二维码</button>
      <button nz-button nzType="primary" style="margin-left: 24px" (click)="submitConfirm('assign')" acl
        [acl-ability]="['SUPPLY-VEHICLE-PLACEORDER-bulkDesignate']">指派熟车</button>
      <!-- <button nz-button nzType="primary"    (click)="choose()">取消</button> -->
      <button nz-button nzType="primary" style="margin-left: 24px" (click)="submitConfirm('publish')" acl
        [acl-ability]="['SUPPLY-VEHICLE-PLACEORDER-bulkAnotherOrder']">司机抢单</button>
    </div>
  </nz-card>
</div>